package com.huxi.lang.object.support;

import java.util.Map;

public class ReflectObject<T> {
	private final Class<T> type;
	private final Map<String, ReflectField> fields;

	ReflectObject(Class<T> type, Map<String, ReflectField> fields) {
		this.type = type;
		this.fields = fields;
	}

	public Class<T> getType() {
		return type;
	}

	public Object get(T target, String key) {
		ReflectField rf = fields.get(key);
		return rf != null ? rf.get(target) : null;
	}

	public void set(T target, String key, Object value) {
		ReflectField rf = fields.get(key);
		if (rf != null) {
			rf.set(target, value);
		}
	}

	public int size() {
		return fields.size();
	}

	public boolean isEmpty() {
		return fields.isEmpty();
	}

	public boolean containsKey(String key) {
		return fields.containsKey(key);
	}

	public Object remove(String key) {
		// TODO Auto-generated method stub
		return null;
	}

}
